package com.zj.user.utils;

import com.zj.user.enums.UserEnum;
import com.zj.user.vo.ResultVo;

/**
 * @Auther: zj
 * @Date: 2018/11/14 10:51
 * @Description:
 */
public class ResultVoUtil {

    public static ResultVo<Object> success(Object object) {
        ResultVo<Object> resultVo=new ResultVo<>();
        resultVo.setCode( 1 );
        resultVo.setMsg( "成功" );
        resultVo.setData( object );
        return resultVo;
    }

    public static ResultVo<Object> success() {
        ResultVo<Object> resultVo=new ResultVo<>();
        resultVo.setCode( 1 );
        resultVo.setMsg( "成功" );
        return resultVo;
    }

    public static ResultVo<Object> error(UserEnum userEnum) {
        ResultVo<Object> resultVo=new ResultVo<>();
        resultVo.setCode( userEnum.getCode());
        resultVo.setMsg( userEnum.getMessage());
        return resultVo;
    }

    public static ResultVo<Object> error(String msg) {
        ResultVo<Object> resultVo=new ResultVo<>();
        resultVo.setCode( -1);
        resultVo.setMsg( msg);
        return resultVo;
    }

}
